﻿using System;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using HiauPdm.Bll;
using HiauPdm.Web;

namespace HiauPdm.Web
{
    public partial class CplbXzMain : PageBase
    {
        protected override bool IsAccess()
        {
            return true;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BtnFind.OnClientClick = "this.disabled=true;" + Page.ClientScript.GetPostBackEventReference(BtnFind, null) + ";return false;";
                TextWhere.Attributes["onkeydown"] = "if(event.keyCode==13){document.getElementById('" + BtnFind.ClientID + "').click();}";
                if ((Request.QueryString["CplbId"] != null) && (Request.QueryString["CplbId"].Trim() != string.Empty))
                {
                    DataSet ds = BCpSjCx.QueryCplb(int.Parse(Request.QueryString["CplbId"].Trim()));
                    GridCplb.DataSource = ds;
                    GridCplb.DataBind();
                }
                TextWhere.Focus();
            }
        }

        protected void BtnFind_Click(object sender, EventArgs e)
        {
            if (TextWhere.Text.Trim() != string.Empty)
            {
                DataSet ds = BCpSjCx.QueryCplb(TextWhere.Text.Trim());
                GridCplb.DataSource = ds;
                GridCplb.DataBind();
            }
            TextWhere.Text = string.Empty;
            TextWhere.Focus();
        }

        protected void GridCplb_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onmouseover"] = "SetColor(this,'','#9DD9DA');";
                e.Row.Attributes["onmouseout"] = "SetColor(this,'','');";
                e.Row.Attributes["onclick"] = "SetResult(this);";
            }
        }
    }
}